<template>
  <div>
    <el-form label-width="200px"  label-position="right" >
      <el-form-item label="员工工号" prop="courseName">
        <el-input v-model="ruleForm.courseName" style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item label="账号" prop="teacherName">
        <el-input v-model="ruleForm.teacherName" style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="courseIntro">
        <el-input v-model="ruleForm.courseIntro" style="width: 300px"></el-input>
      </el-form-item>
      <el-form-item label="级别" prop="courseStyle">
        <el-radio v-model="ruleForm.courseStyle" label="4" border >一级系统管理员</el-radio>
        <el-radio v-model="ruleForm.courseStyle" label="6" border >二级数据管理员</el-radio>
      </el-form-item>
     <el-form-item>
      <el-button type="success" @click="submitForm('ruleForm')">注册</el-button>
      <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
    import {validateChinese} from "../../tools/validate";

    export default {
        name: "SysManageAdd",
      //生成未选择的数据
      data() {

        return {
          //上传文件的控件数据
          fileList: [{name: 'food.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}, {name: 'food2.jpeg', url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'}],
          //控制课程类型子组件的显示
          isShowAddVideo:false,
          isShowAddPlace:false,
          //表单的各个数据项的值
          ruleForm: {
            courseName:'',
            teacherName:'',
            courseIntro:'',
            courseStyle:'',
            examineType:'',
            courseDir:'',
            studyPlace:'',
            testPlace:''

          },
          rules: {
            courseName: [
              { required: true, message: '请输入课程名称', trigger: 'blur' },
              { min: 0, max: 15, message: '长度在 0 到 15 个字符', trigger: 'blur' },
            ],
            teacherName: [
              { required: true, message: '请输入讲师名称', trigger: 'blur' },
              { min: 0, max: 8, message: '长度在 0 到 8 个字符', trigger: 'blur' },
              {validator:validateChinese,trigger: 'blur'}

            ],
            courseIntro:[
              { required: true, message: '请输入课程简介', trigger: 'blur' },
            ],
            courseStyle:[
              { required: true, message: '请选择至少一种类型', trigger: 'blur' },
            ],
            examineType:[
              { required: true, message: '请选择至少一种类型', trigger: 'blur' },
            ],
            courseDir:[
              { required: true, message: '请选择至少一种方向', trigger: 'blur' },
            ],
            studyPlace:[
              { required: true, message: '请填写上课地点', trigger: 'blur' },
            ],
            testPlace:[
              { required: true, message: '请填写考试地点', trigger: 'blur' },
            ],
          },

        };
      },
      methods:{
        //表单提交
        submitForm(formName) {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              alert('submit!');
            } else {
              console.log('error submit!!');
              return false;
            }
          });
          this.flush();
        },
        //重置表单数据
        resetForm(formName) {
          this.$refs[formName].resetFields();
          this.isShowAddVideo=false;
          this.isShowAddPlace=false;
          this.isShowAddtest=false;
          this.isShowAddtestPlace=false;
        },

      }
    }
</script>

<style scoped>

</style>
